﻿using System;
using System.Diagnostics;
using Autofac;
using Microsoft.Practices.Unity;
using NUnit.Framework;
using ReactiveGraph.Core.Configuration.Containers;
using ReactiveGraph.Object.Configuration;
using ReactiveGraph.Object.Configuration.Containers;

namespace ReactiveGraph.Object.Tests
{   
    [Explicit]
    [TestFixture]
    public class PerformanceTests
    {
        [SetUp]
        public void Setup()
        {
          
        }

        [Test]
        public void UnityTest()
        {
            var container = new UnityContainer();
            container.AddExtension(new UnityObjectExtension());
           

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                container.Resolve<Foo>();
            }
            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);
            
        }

        [Test]
        public void AutofacTest()
        {
            var builder = new ContainerBuilder();
            builder.RegisterModule(new AutofacObjectModule());
          
            var container = builder.Build();
          
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            for (var i = 0; i < 5000; i++)
            {
                container.Resolve<Foo>();
            }
            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds);

        }
    }
}
